package nl.windgazer.facebook.components;

import nl.windgazer.arachne.services.facebook.FacebookAPISettings;

import org.apache.tapestry5.BindingConstants;
import org.apache.tapestry5.annotations.BeforeRenderTemplate;
import org.apache.tapestry5.annotations.Import;
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.ioc.annotations.Inject;

@Import(library={"classpath:/nl/windgazer/jsrepository/Events.js", "classpath:/nl/windgazer/jsrepository/LinkListener.js", "Logout.js"})
public class Login extends XFBMLElement {

	//Injects and Persists

	@Inject
	private FacebookAPISettings fapis;

	//Properties and Parameters

	@Parameter(required = false, principal = false, defaultPrefix = BindingConstants.PROP, name = "max_rows")
	private Integer _maxrows = 1;

	@SuppressWarnings("unused")
	@Parameter(required = false, principal = false, defaultPrefix = BindingConstants.PROP, name = "registration_url")
	private String _registrationUrl;

	//Components

	//Events

	@BeforeRenderTemplate
	void setupLoginBox() {
		if (!fapis.isVerified()) {
			setTag("login-button");
			setAttribs("max-rows", _maxrows.toString());
		} else {
			setCancelRender(true);
		}
	}

	//Other (check for business-logic, it should not remain here)

}
